<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

<rich:panel header="#{messages['agent.list']}">
	
	<t:panelGrid columns="2" columnClasses="standardTable_ColumnLeft_20,standardTable_ColumnLeft_80" width="100%">
		<h:outputLabel for="code" value="#{messages['agent.registration.no']}" styleClass="standardText_Label" />
		<t:inputText id="code"  size="30" maxlength="50" styleClass="standardText" value="#{adminAgentMgmtBean.regno}"></t:inputText>
		
		<h:outputLabel for="cname" value="#{messages['company.name']}" styleClass="standardText_Label" />
		<t:inputText id="cname"  size="30" maxlength="50" styleClass="standardText" value="#{adminAgentMgmtBean.name}"></t:inputText>
		
		<t:outputText></t:outputText>
		<h:commandButton value="#{messages['search']}" styleClass="button"  action="#{adminAgentMgmtBean.searchAction}"></h:commandButton>
	</t:panelGrid>
	
	<rich:spacer height="20" />
	
	<rich:dataTable id="data" var="obj" value="#{adminAgentMgmtBean.agentList}" rows="10" width="99%" rowKeyVar="rowNo">
		<rich:column style="text-align:center;width:5%;" >
			<f:facet name="header">
				<h:selectBooleanCheckbox id="chkAll" onclick="checkAll(this.form,this)" ></h:selectBooleanCheckbox>
			</f:facet>
			<h:selectBooleanCheckbox id="chk" value=""></h:selectBooleanCheckbox>
		</rich:column>
		<rich:column style="text-align:center;width:15%;">
			<f:facet name="header">
				<h:outputText value="#{messages['registration.no']}"></h:outputText>
			</f:facet>
			<h:commandLink action="#{adminAgentMgmtBean.navAgentProfile}" actionListener="#{adminAgentMgmtBean.agentProfileActionListener}" value="#{obj.agentRegNo}"> 
			</h:commandLink>
			<f:param id="profileid" value="#{obj.agentId}"/>
			<%--<t:outputText styleClass="standardText" value="#{obj.agentRegNo}"></t:outputText>--%>
		</rich:column>
		<rich:column style="text-align:center;width:15%;">
			<f:facet name="header">
				<h:outputText value="#{messages['contact.person']}"></h:outputText>
			</f:facet>
			<t:outputText styleClass="standardText" value="#{obj.contactPerson}"></t:outputText>
		</rich:column>
		<rich:column style="text-align:center;width:15%;">
			<f:facet name="header">
				<h:outputText value="#{messages['company.name']}"></h:outputText>
			</f:facet>
			<t:outputText styleClass="standardText" value="#{obj.compName}"></t:outputText>
		</rich:column>
		<rich:column style="text-align:center;width:13%;">
			<f:facet name="header">
				<h:outputText value="#{messages['status']}"></h:outputText>
			</f:facet>
			<t:outputText styleClass="standardText" value="#{obj.statusLabel}"></t:outputText>
		</rich:column>
		<rich:column style="text-align:center;width:13%;">
			<f:facet name="header">
				<h:outputText value="#{messages['agreement.control']}"></h:outputText>
			</f:facet>
			<h:commandButton styleClass="button" value="#{messages['action']}" action="#{adminAgentMgmtBean.navAgreementControl}" actionListener="#{adminAgentMgmtBean.agreementControlActionListener}"></h:commandButton>
			<f:param id="id" value="#{obj.agentId}"/>
		</rich:column>
		<rich:column style="text-align:center;width:13%;">
			<f:facet name="header">
				<h:outputText value="#{messages['commission']}"></h:outputText>
			</f:facet>
			<h:commandButton styleClass="button" value="#{messages['action']}" action="#{adminAgentMgmtBean.navAgentComm}" actionListener="#{adminAgentMgmtBean.agentCommActionListener}"></h:commandButton>
			<f:param id="aid" value="#{obj.agentId}"/>
		</rich:column>
		<rich:column style="text-align:center;width:13%;" rendered="#{adminAgentMgmtBean.canTransferAgreement}">
			<f:facet name="header">
				<h:outputText value="Agreement Transfer"></h:outputText>
			</f:facet>
			<h:commandButton rendered="#{!(obj.status=='Terminated')}" styleClass="button" value="#{messages['action']}"  action="#{adminAgentMgmtBean.navAgreementTransfer}" actionListener="#{adminAgentMgmtBean.navAgreementTransferListener}"></h:commandButton>
			<f:param id="agentId2" value="#{obj.agentId}"/>
		</rich:column>
		<rich:column style="text-align:center;width:13%;" rendered="#{adminAgentMgmtBean.canTransferAgreement}">
			<f:facet name="header">
				<h:outputText value="Terminate Agent"></h:outputText>
			</f:facet>
			<h:commandButton rendered="#{!(obj.status=='Terminated')}" styleClass="button" value="#{messages['action']}" actionListener="#{adminAgentMgmtBean.terminateActionListener}"></h:commandButton>
			<f:param id="agentId3" value="#{obj.agentId}"/>
		</rich:column>
	</rich:dataTable>
	 
	<rich:spacer height="30" />
	
	<rich:datascroller align="left"  for="data" maxPages="20" />

	<rich:spacer height="30" />
	
	<t:panelGrid columns="1" width="100%">
		<t:panelGroup>
			<%--<h:commandButton value="#{messages['delete']}" styleClass="button"  immediate="true" action=""></h:commandButton>
		 	<f:verbatim>&nbsp;</f:verbatim>--%>
		 	<h:commandButton value="#{messages['create']}" styleClass="button"  immediate="true" action="#{adminAgentRegBean.navRegAgent}"></h:commandButton>
		 	<f:verbatim>&nbsp;</f:verbatim>
   			<h:commandButton value="#{messages['cancel']}" styleClass="button" immediate="true" action="#{adminAgentMgmtBean.backAction}"></h:commandButton>
   		</t:panelGroup>
	</t:panelGrid>
</rich:panel>
<h:commandButton value="Generate Commission" styleClass="button"  immediate="true" action="#{adminAgentMgmtBean.comAction}"></h:commandButton>
		